/*
 * © Copyright 2011 Romain Marteau, Matthieu Totet
 * 
 *    This file is part of VineaToum.
 *
 *    VineaToum is free software: you can redistribute it and/or modify
 *    it under the terms of the GNU General Public License as published by
 *    the Free Software Foundation, either version 3 of the License, or
 *    (at your option) any later version.
 *
 *    VineaToum is distributed in the hope that it will be useful,
 *    but WITHOUT ANY WARRANTY; without even the implied warranty of
 *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *    GNU General Public License for more details.
 *
 *    You should have received a copy of the GNU General Public License
 *    along with VineaToum.  If not, see <http://www.gnu.org/licenses/>.
 *    
 */

package org.vineatoum.view.action;

import javax.swing.JPanel;
import java.awt.GridBagLayout;

import javax.swing.JLabel;
import java.awt.GridBagConstraints;
import java.awt.Insets;

import javax.swing.BoxLayout;
import javax.swing.JCheckBox;
import javax.swing.JSpinner;
import javax.swing.SpinnerNumberModel;

import org.vineatoum.business.action.operationactive.Pressurage;
import org.vineatoum.model.abstraction.IVineaToumModel;

import com.toedter.calendar.JDateChooser;

public class PressuragePanel extends JPanel {
	private static final long serialVersionUID = -6779005200522265769L;
	
	private JDateChooser dateChooserDate;
	private JSpinner spinnerDuree;
	
	private JCheckBox checkBoxMaceration;
	private JSpinner spinnerDureeMaceration;
	
	private JCheckBox checkBoxInertage;
	
	private EncuvagePanel encuvagePanel;

	/**
	 * Create the panel.
	 * 
	 * @param soutirage
	 * @param model
	 */
	public PressuragePanel(IVineaToumModel model, Pressurage pressurage) {
		setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
		
		JPanel dataPanel = new JPanel();
		
		GridBagLayout gbl_panel = new GridBagLayout();
		gbl_panel.columnWidths = new int[] { 0, 0, 0, 0, 0, 0, 0, 0 };
		gbl_panel.rowHeights = new int[] { 0, 0, 0 };
		gbl_panel.columnWeights = new double[] { 0.0, 0.0, 0.0, 0.0,
				0.0, 0.0, 0.0, Double.MIN_VALUE };
		gbl_panel.rowWeights = new double[] { 0.0, 0.0,
				Double.MIN_VALUE };
		dataPanel.setLayout(gbl_panel);
		
		{
			JLabel lblDate = new JLabel("Date du pressurage");
			GridBagConstraints gbc_lblDate = new GridBagConstraints();
			gbc_lblDate.insets = new Insets(0, 0, 5, 5);
			gbc_lblDate.anchor = GridBagConstraints.EAST;
			gbc_lblDate.gridx = 1;
			gbc_lblDate.gridy = 0;
			dataPanel.add(lblDate, gbc_lblDate);
		}
		{
			dateChooserDate = new JDateChooser();
			GridBagConstraints gbc_textField = new GridBagConstraints();
			gbc_textField.insets = new Insets(0, 0, 5, 5);
			gbc_textField.fill = GridBagConstraints.HORIZONTAL;
			gbc_textField.gridx = 2;
			gbc_textField.gridy = 0;
			dataPanel.add(dateChooserDate, gbc_textField);
		}
		{
			JLabel lblLieQte = new JLabel("Durée");
			GridBagConstraints gbc_lblTemprature = new GridBagConstraints();
			gbc_lblTemprature.anchor = GridBagConstraints.EAST;
			gbc_lblTemprature.insets = new Insets(0, 0, 5, 5);
			gbc_lblTemprature.gridx = 4;
			gbc_lblTemprature.gridy = 0;
			dataPanel.add(lblLieQte, gbc_lblTemprature);
		}
		{
			spinnerDuree = new JSpinner();
			spinnerDuree.setModel(new SpinnerNumberModel(new Float(0.5),
					new Float(0), new Float(9999), new Float(0.1)));
			GridBagConstraints gbc_textField_1 = new GridBagConstraints();
			gbc_textField_1.insets = new Insets(0, 0, 5, 5);
			gbc_textField_1.fill = GridBagConstraints.HORIZONTAL;
			gbc_textField_1.gridx = 5;
			gbc_textField_1.gridy = 0;
			dataPanel.add(spinnerDuree, gbc_textField_1);
		}
		{
			checkBoxMaceration = new JCheckBox("Macération pelliculaire");
			GridBagConstraints gbc_textField_1 = new GridBagConstraints();
			gbc_textField_1.insets = new Insets(0, 0, 0, 5);
			gbc_textField_1.fill = GridBagConstraints.HORIZONTAL;
			gbc_textField_1.gridx = 1;
			gbc_textField_1.gridy = 1;
			dataPanel.add(checkBoxMaceration, gbc_textField_1);
		}
		{
			spinnerDureeMaceration = new JSpinner();
			spinnerDureeMaceration.setModel(new SpinnerNumberModel(new Float(0.5),
					new Float(0), new Float(9999), new Float(0.1)));
			GridBagConstraints gbc_textField_1 = new GridBagConstraints();
			gbc_textField_1.insets = new Insets(0, 0, 0, 5);
			gbc_textField_1.fill = GridBagConstraints.HORIZONTAL;
			gbc_textField_1.gridx = 2;
			gbc_textField_1.gridy = 1;
			dataPanel.add(spinnerDureeMaceration, gbc_textField_1);
		}
		{
			encuvagePanel = new EncuvagePanel(model, pressurage.getEncuvage());
		}
		
		add(dataPanel);
		{
			checkBoxInertage = new JCheckBox("Inertage");
			GridBagConstraints gbc_textField_1 = new GridBagConstraints();
			gbc_textField_1.gridwidth = 2;
			gbc_textField_1.insets = new Insets(0, 0, 0, 5);
			gbc_textField_1.fill = GridBagConstraints.HORIZONTAL;
			gbc_textField_1.gridx = 4;
			gbc_textField_1.gridy = 1;
			dataPanel.add(checkBoxInertage, gbc_textField_1);
		}
		add(encuvagePanel);
	}
}
